package com.example.administrator.rfid;

import android.app.PendingIntent;
import android.content.IntentFilter;
import android.nfc.NfcAdapter;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.newland.rfid_demo.HightFrequencyThread;

import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {
    private HightFrequencyThread hft;
    private String str;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        hft = HightFrequencyThread.getInstance(3, 0, 6);
        hft.setgetDataCallBack(new HightFrequencyThread.GetDataCallBack() {

            @Override
            public void searchLabel(int arg0, List<String> arg1, int arg2) {
                // TODO Auto-generated method stub
                str = arg1.get(0);
                Log.i("Tag", str);
                hft.read((byte) 0x03, str);
                SystemClock.sleep(50);
            }

            @Override
            public void getData(int arg0, String arg1, int arg2) {
                // TODO Auto-generated method stub
                Log.i("Tag", arg1);
            }
        });
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {

            @Override
            public void run() {
                // TODO Auto-generated method stub

                hft.searchLabel();
            }
        }, 1000, 1000);
    }
}